﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using ColumnModuleAndEdit.DataDefine;
using ColumnModuleAndEdit.Properties;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YArchitech.Revit;
using YJKArchMethodLibrary.Utils;
using YJKCodeBase.WinForm.HookSuit;
using YRevitJig;
using YJKTools.PublicPreViewer;

namespace ColumnModuleAndEdit.Forms
{
	public partial class ColumnInsertDlg : System.Windows.Forms.Form
	{
		public ColumnInsertDlg(UIDocument uiDoc, IntPtr handle)
		{
			this.InitializeComponent();
			this.m_Uidoc = uiDoc;
			this.m_doc = uiDoc.Document;
			this.m_iHandle = handle;
			this.m_fySymbolManage = new FamilySymbolManage(this.m_doc);
			this.m_dCurHeight = this.GetCurLevelHeight(this.m_doc);
			this.m_PreviewNew = new Previewer(this.TabNew, this.picPreview.Left, this.picPreview.Top, this.picPreview.Width, this.picPreview.Height, 1u);
			this.picPreview.Visible = false;
			base.MouseWheel += this.m_PreviewNew.MouseWheel;
			this.m_PreviewCur = new Previewer(this.tabCur, this.picCurPreview.Left, this.picCurPreview.Top, this.picCurPreview.Width, this.picCurPreview.Height, 1u);
			this.picCurPreview.Visible = false;
			base.MouseWheel += this.m_PreviewCur.MouseWheel;
			ToolTip toolTip = new ToolTip();
			toolTip.SetToolTip(this.btnPickPt, "自由布置");
			ToolTip toolTip2 = new ToolTip();
			toolTip2.SetToolTip(this.btnPickAxis, "沿所选轴线布置柱子");
			ToolTip toolTip3 = new ToolTip();
			toolTip3.SetToolTip(this.btnPickRect, "所选范围内的轴线交点布置柱子");
			ToolTip toolTip4 = new ToolTip();
			toolTip4.SetToolTip(this.btnClone, "替换图中已布置柱子");
			ToolTip toolTip5 = new ToolTip();
			toolTip5.SetToolTip(this.btnPickColumn, "拾取已布置柱子");
		}

		public ColumnDatum GetColumnData()
		{
			ColumnDatum columnDatum = new ColumnDatum(this.m_doc);
			if (this.tab.SelectedIndex == 0)
			{
				ColumnType columnTypeInTabNew = this.GetColumnTypeInTabNew();
				columnDatum.ColSym = this.m_fySymbolManage.GetColumnFsByParaInfo(columnTypeInTabNew, this.cmbXLength.Text, this.cmbYLength.Text, this.cmbMaterial.Text);
				if (columnTypeInTabNew == ColumnType.eArchCircleColumn || columnTypeInTabNew == ColumnType.eArchRectColumn || columnTypeInTabNew == ColumnType.eArchOtherColumn)
				{
					columnDatum.IsArch = true;
				}
				else
				{
					columnDatum.IsArch = false;
				}
				Material materialObject = FamilySymbolManage.GetMaterialObject(this.m_doc, this.cmbMaterial.Text);
				if (materialObject != null)
				{
					columnDatum.MateralId = materialObject.Id;
				}
				double dBaseOffset = 0.0;
				double.TryParse(this.cmbBaseOffset.Text, out dBaseOffset);
				double dHeight = 0.0;
				if (double.TryParse(this.cmbHeight.Text, out dHeight))
				{
					columnDatum.SetTopBottomOffset(dHeight, dBaseOffset);
				}
				else if (this.cmbHeight.Text == "当前层高")
				{
					columnDatum.SetTopBottomOffset(this.m_dCurHeight, dBaseOffset);
				}
				double angle = 0.0;
				if (double.TryParse(this.cmbCorner.Text, out angle))
				{
					columnDatum.Angle = angle;
				}
			}
			else
			{
				ColumnType columnTypeInTabNew2 = this.GetColumnTypeInTabNew();
				if (columnTypeInTabNew2 == ColumnType.eArchCircleColumn || columnTypeInTabNew2 == ColumnType.eArchRectColumn || columnTypeInTabNew2 == ColumnType.eArchOtherColumn)
				{
					columnDatum.IsArch = true;
				}
				else
				{
					columnDatum.IsArch = false;
				}
				TreeNode selectedNode = this.treeView.SelectedNode;
				if (selectedNode != null)
				{
					columnDatum.ColSym = (selectedNode.Tag as FamilySymbol);
				}
				Material materialObject2 = FamilySymbolManage.GetMaterialObject(this.m_doc, this.cmbCurMaterial.Text);
				if (materialObject2 != null)
				{
					columnDatum.MateralId = materialObject2.Id;
				}
				double dBaseOffset2 = 0.0;
				double.TryParse(this.cmbCurBaseOffset.Text, out dBaseOffset2);
				double dHeight2 = 0.0;
				if (double.TryParse(this.cmbCurHeight.Text, out dHeight2))
				{
					columnDatum.SetTopBottomOffset(dHeight2, dBaseOffset2);
				}
				else if (this.cmbCurHeight.Text == "当前层高")
				{
					columnDatum.SetTopBottomOffset(this.m_dCurHeight, dBaseOffset2);
				}
				double angle2 = 0.0;
				if (double.TryParse(this.cmbCurCorner.Text, out angle2))
				{
					columnDatum.Angle = angle2;
				}
			}
			return columnDatum;
		}

		public CreateColumnType GetCreateColType()
		{
			return this.m_eCreateColumnType;
		}

		public void SetCreateColType(CreateColumnType eCreateColumnType)
		{
			this.m_eCreateColumnType = eCreateColumnType;
		}

		private ColumnType GetColumnTypeInTabNew()
		{
			ColumnType result;
			if (this.cmbMajor.Text == "建筑")
			{
				if (this.cmbShape.Text == "矩形柱")
				{
					result = ColumnType.eArchRectColumn;
				}
				else if (this.cmbShape.Text == "圆柱")
				{
					result = ColumnType.eArchCircleColumn;
				}
				else
				{
					result = ColumnType.eArchOtherColumn;
				}
			}
			else if (this.cmbShape.Text == "矩形柱")
			{
				result = ColumnType.eStruRectColumn;
			}
			else if (this.cmbShape.Text == "圆柱")
			{
				result = ColumnType.eStruCircleColumn;
			}
			else
			{
				result = ColumnType.eStruOtherColumn;
			}
			return result;
		}

		private void IniData()
		{
			this.m_ColumnData = new ColumnInsetData();
			this.cmbMajor.Items.Clear();
			foreach (string item in this.m_ColumnData.GetLstMajor())
			{
				this.cmbMajor.Items.Add(item);
			}
			this.cmbShape.Items.Clear();
			foreach (string item2 in this.m_ColumnData.GetLstShape())
			{
				this.cmbShape.Items.Add(item2);
			}
			this.cmbMaterial.Items.Clear();
			foreach (string item3 in this.m_ColumnData.GetLstMaterial())
			{
				this.cmbMaterial.Items.Add(item3);
			}
			foreach (string item4 in this.m_ColumnData.GetLstXLength())
			{
				this.cmbXLength.AddItem(item4);
			}
			foreach (string item5 in this.m_ColumnData.GetLstYLength())
			{
				this.cmbYLength.AddItem(item5);
			}
			foreach (string item6 in this.m_ColumnData.GetLstHeight())
			{
				this.cmbHeight.AddItem(item6);
			}
			foreach (string item7 in this.m_ColumnData.GetLstBaseOffset())
			{
				this.cmbBaseOffset.AddItem(item7);
			}
			foreach (string item8 in this.m_ColumnData.GetLstCorner())
			{
				this.cmbCorner.AddItem(item8);
			}
			this.cmbMajor.Text = this.m_ColumnData.Major;
			this.cmbShape.Text = this.m_ColumnData.Shape;
			this.cmbMaterial.Text = this.m_ColumnData.Material;
			if (this.m_ColumnData.Shape == "圆柱")
			{
				this.cmbXLength.Text = this.m_ColumnData.Radius;
				this.cmbYLength.Text = this.m_ColumnData.Diameter;
			}
			else
			{
				this.cmbXLength.Text = this.m_ColumnData.XLength;
				this.cmbYLength.Text = this.m_ColumnData.YLength;
			}
			this.cmbHeight.Text = this.m_ColumnData.Height;
			this.cmbBaseOffset.Text = this.m_ColumnData.BaseOffset;
			this.cmbCorner.Text = this.m_ColumnData.Corner;
			this.cmbCurMajor.Items.Add("建筑");
			this.cmbCurMajor.Items.Add("结构");
			this.cmbCurShape.Items.Add("圆柱");
			this.cmbCurShape.Items.Add("矩形柱");
			this.cmbCurShape.Items.Add("其他");
			foreach (string item9 in this.m_ColumnData.GetLstHeightCur())
			{
				this.cmbCurHeight.AddItem(item9);
			}
			foreach (string item10 in this.m_ColumnData.GetLstBaseOffsetCur())
			{
				this.cmbCurBaseOffset.AddItem(item10);
			}
			foreach (string item11 in this.m_ColumnData.GetLstCornerCur())
			{
				this.cmbCurCorner.AddItem(item11);
			}
			this.cmbCurHeight.Text = this.m_ColumnData.HeightCur;
			this.cmbCurBaseOffset.Text = this.m_ColumnData.BaseOffsetCur;
			this.cmbCurCorner.Text = this.m_ColumnData.CornerCur;
			this.m_eCreateColumnType = CreateColumnType.eSelectPoint;
			this.UpdataTabSelectedIndex();
		}

		private void NodeAddFamilySymbol(ref TreeNode node, List<FamilySymbol> lstFamilySymbol)
		{
			foreach (FamilySymbol familySymbol in lstFamilySymbol)
			{
				TreeNode treeNode = new TreeNode();
				treeNode.Text = familySymbol.Name;
				treeNode.Tag = familySymbol;
				node.Nodes.Add(treeNode);
			}
		}

		private List<FamilySymbol> SortTreeNodeName(List<FamilySymbol> lstFiSymbolName, List<string> lstName)
		{
			List<FamilySymbol> list = new List<FamilySymbol>();
			if (lstName == null || lstName.Count == 0)
			{
				list.AddRange(lstFiSymbolName);
			}
			else
			{
				foreach (string a in lstName)
				{
					for (int i = 0; i < lstFiSymbolName.Count; i++)
					{
						if (lstFiSymbolName[i] != null && a == lstFiSymbolName[i].Name)
						{
							list.Add(lstFiSymbolName[i]);
							lstFiSymbolName.RemoveAt(i);
							i--;
						}
					}
				}
				list.AddRange(lstFiSymbolName);
			}
			return list;
		}

		private void TreeNodesIni()
		{
			this.treeView.Nodes.Clear();
			List<FamilySymbol> columnFiSymbolsByDoc = this.m_fySymbolManage.GetColumnFiSymbolsByDoc(BuiltInCategory.OST_Columns);
			List<FamilySymbol> list = this.m_fySymbolManage.GetColumnFiSymbolsByType(columnFiSymbolsByDoc, ColumnType.eArchRectColumn);
			List<FamilySymbol> list2 = this.m_fySymbolManage.GetColumnFiSymbolsByType(columnFiSymbolsByDoc, ColumnType.eArchCircleColumn);
			List<FamilySymbol> list3 = this.m_fySymbolManage.GetColumnFiSymbolsByType(columnFiSymbolsByDoc, ColumnType.eArchOtherColumn);
			list = this.SortTreeNodeName(list, this.m_ColumnData.GetLstArchRectFiSymbol());
			list2 = this.SortTreeNodeName(list2, this.m_ColumnData.GetLstArchCircleFiSymbol());
			list3 = this.SortTreeNodeName(list3, this.m_ColumnData.GetLstArchOtherFiSymbol());
			TreeNode treeNode = new TreeNode();
			treeNode.Text = "建筑";
			this.treeView.Nodes.Add(treeNode);
			TreeNode treeNode2 = new TreeNode();
			treeNode2.Text = "矩形柱";
			this.NodeAddFamilySymbol(ref treeNode2, list);
			treeNode.Nodes.Add(treeNode2);
			TreeNode treeNode3 = new TreeNode();
			treeNode3.Text = "圆柱";
			this.NodeAddFamilySymbol(ref treeNode3, list2);
			treeNode.Nodes.Add(treeNode3);
			TreeNode treeNode4 = new TreeNode();
			treeNode4.Text = "其他";
			this.NodeAddFamilySymbol(ref treeNode4, list3);
			treeNode.Nodes.Add(treeNode4);
			List<FamilySymbol> columnFiSymbolsByDoc2 = this.m_fySymbolManage.GetColumnFiSymbolsByDoc(BuiltInCategory.OST_StructuralColumns);
			List<FamilySymbol> list4 = this.m_fySymbolManage.GetColumnFiSymbolsByType(columnFiSymbolsByDoc2, ColumnType.eStruRectColumn);
			List<FamilySymbol> list5 = this.m_fySymbolManage.GetColumnFiSymbolsByType(columnFiSymbolsByDoc2, ColumnType.eStruCircleColumn);
			List<FamilySymbol> list6 = this.m_fySymbolManage.GetColumnFiSymbolsByType(columnFiSymbolsByDoc2, ColumnType.eStruOtherColumn);
			list4 = this.SortTreeNodeName(list4, this.m_ColumnData.GetLstStruRectFiSymbol());
			list5 = this.SortTreeNodeName(list5, this.m_ColumnData.GetLstStruCircleFiSymbol());
			list6 = this.SortTreeNodeName(list6, this.m_ColumnData.GetLstStruOtherFiSymbol());
			TreeNode treeNode5 = new TreeNode();
			treeNode5.Text = "结构";
			this.treeView.Nodes.Add(treeNode5);
			TreeNode treeNode6 = new TreeNode();
			treeNode6.Text = "矩形柱";
			this.NodeAddFamilySymbol(ref treeNode6, list4);
			treeNode5.Nodes.Add(treeNode6);
			TreeNode treeNode7 = new TreeNode();
			treeNode7.Text = "圆柱";
			this.NodeAddFamilySymbol(ref treeNode7, list5);
			treeNode5.Nodes.Add(treeNode7);
			TreeNode treeNode8 = new TreeNode();
			treeNode8.Text = "其他";
			this.NodeAddFamilySymbol(ref treeNode8, list6);
			treeNode5.Nodes.Add(treeNode8);
			TreeNode treeNode9 = this.FirstTNode();
			this.treeView.Focus();
			if (treeNode9 != null)
			{
				TreeNode selectedNode = this.treeView.SelectedNode;
				if (selectedNode != null)
				{
					selectedNode.Checked = false;
				}
				treeNode9.Checked = true;
				this.treeView.SelectedNode = treeNode9;
				this.SelectTreeNode(treeNode9.Tag as FamilySymbol, true);
			}
		}

		private TreeNode FirstTNode()
		{
			TreeNode treeNode = null;
			if (this.treeView == null || this.treeView.Nodes.Count == 0)
			{
				return treeNode;
			}
			TreeNode treeNode2 = this.treeView.Nodes[0];
			if (treeNode2.Nodes.Count > 0)
			{
				treeNode = treeNode2.Nodes[0];
			}
			if (treeNode != null && treeNode.Nodes.Count > 0)
			{
				treeNode = treeNode.Nodes[0];
			}
			return treeNode;
		}

		public void TabNewToTabCur()
		{
			if (this.tab.SelectedIndex == 0)
			{
				this.tab.SelectedIndex = 1;
			}
		}

		public void SelectTreeNode(FamilySymbol fiSymbol, bool bFlag = true)
		{
			this.m_bDoHook = bFlag;
			if (fiSymbol == null)
			{
				return;
			}
			int num = 0;
			int num2 = 0;
			ColumnType columnType = ColumnType.eArchOtherColumn;
			FamilySymbolManage.GetShapeTypeByFiSymbol(fiSymbol, ref columnType, ref num, ref num2);
			string text = "其他";
			if (columnType == ColumnType.eArchRectColumn || columnType == ColumnType.eStruRectColumn)
			{
				text = "矩形柱";
			}
			else if (columnType == ColumnType.eArchCircleColumn || columnType == ColumnType.eStruCircleColumn)
			{
				text = "圆柱";
			}
			string text2 = "结构";
			if (fiSymbol.Category.Id.IntegerValue == -2000100)
			{
				text2 = "建筑";
			}
			string strTNodeName = string.Concat(new string[]
			{
				text2,
				"+",
				text,
				"+",
				fiSymbol.Name
			});
			TreeNode treeNodeByFsName = this.GetTreeNodeByFsName(strTNodeName);
			if (treeNodeByFsName != null)
			{
				this.treeView.SelectedNode.Checked = false;
				treeNodeByFsName.Checked = true;
				this.treeView.SelectedNode = treeNodeByFsName;
			}
		}

		public void SetDlgBySymbol(FamilySymbol fiSymbol)
		{
			if (fiSymbol == null)
			{
				return;
			}
			int num = 0;
			int num2 = 0;
			ColumnType columnType = ColumnType.eArchOtherColumn;
			FamilySymbolManage.GetShapeTypeByFiSymbol(fiSymbol, ref columnType, ref num, ref num2);
			string text = "其他";
			if (columnType == ColumnType.eArchRectColumn || columnType == ColumnType.eStruRectColumn)
			{
				text = "矩形柱";
				this.lblCurXLength.Text = "横向(mm)：";
				this.lblCurYLength.Text = "纵向(mm)：";
			}
			else if (columnType == ColumnType.eArchCircleColumn || columnType == ColumnType.eStruCircleColumn)
			{
				text = "圆柱";
				this.lblCurXLength.Text = "半径(mm)：";
				this.lblCurYLength.Text = "直径(mm)：";
			}
			string text2 = "";
			string text3 = "结构";
			if (fiSymbol.Category.Id.IntegerValue == -2000100)
			{
				text3 = "建筑";
				Parameter parameter = fiSymbol.GetParameter("材质");
				if (parameter != null)
				{
					text2 = parameter.AsValueString();
				}
			}
			else
			{
				string[] array = fiSymbol.Name.Split(new char[]
				{
					'-'
				});
				if (array.Count<string>() > 0)
				{
					text2 = array[0];
				}
			}
			if (text2.Contains("HY_"))
			{
				string[] array2 = text2.Split(new char[]
				{
					'_'
				});
				if (array2.Count<string>() > 1)
				{
					text2 = array2[1];
				}
			}
			if (!this.cmbCurShape.Items.Contains(text))
			{
				this.cmbCurShape.Items.Add(text);
			}
			this.cmbCurShape.Text = text;
			if (!this.cmbCurMajor.Items.Contains(text3))
			{
				this.cmbCurMajor.Items.Add(text3);
			}
			this.cmbCurMajor.Text = text3;
			if (!this.cmbCurMaterial.Items.Contains(text2))
			{
				this.cmbCurMaterial.Items.Add(text2);
			}
			this.cmbCurMaterial.Text = text2;
			this.cmbCurXLength.Text = num.ToString();
			this.cmbCurYLength.Text = num2.ToString();
		}

		private TreeNode GetTreeNodeByFsName(string strTNodeName)
		{
			if (strTNodeName == null)
			{
				return null;
			}
			string b = "建筑";
			string b2 = "矩形柱";
			string b3 = "457 x 475mm";
			string[] array = strTNodeName.Split(new char[]
			{
				'+'
			});
			if (array.Length == 3)
			{
				b = array[0];
				b2 = array[1];
				b3 = array[2];
			}
			TreeNode treeNode = null;
			foreach (object obj in this.treeView.Nodes)
			{
				TreeNode treeNode2 = (TreeNode)obj;
				if (treeNode2.Text == b)
				{
					treeNode = treeNode2;
					break;
				}
			}
			TreeNode treeNode3 = null;
			foreach (object obj2 in treeNode.Nodes)
			{
				TreeNode treeNode4 = (TreeNode)obj2;
				if (treeNode4.Text == b2)
				{
					treeNode3 = treeNode4;
					break;
				}
			}
			TreeNode result = null;
			foreach (object obj3 in treeNode3.Nodes)
			{
				TreeNode treeNode5 = (TreeNode)obj3;
				if (treeNode5.Text == b3)
				{
					result = treeNode5;
					break;
				}
			}
			return result;
		}

		private void btnCurCorner_Click(object sender, EventArgs e)
		{
			base.Hide();
			this.m_bDoHook = false;
			try
			{
				this.m_bIsLevelDlg = true;
				double num = 0.0;
				if (this.GetAngle(ref num))
				{
					num = num * 180.0 / Math.PI;
					int num2 = (int)num;
					if (Geometry.LessThan(num - (double)num2, 0.5))
					{
						num2++;
					}
					this.cmbCurCorner.Text = num2.ToString();
				}
			}
			catch (Exception)
			{
			}
			base.Show();
			this.m_bDoHook = true;
			this.SetCurPosToCtrl(this.cmbCurCorner);
		}

		private void UpdataTabSelectedIndex()
		{
			if (this.tab.SelectedIndex == 0)
			{
				base.Width -= this.pnlTree.Width;
				this.pnlTree.Hide();
				this.m_eCreateColumnType = CreateColumnType.eSelectPoint;
				this.SetTreeDataToColumnData();
				return;
			}
			this.TreeNodesIni();
			base.Width += this.pnlTree.Width;
			this.pnlTree.Show();
		}

		private void tab_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.UpdataTabSelectedIndex();
		}

		private void UpdateYLength()
		{
			string text = this.cmbYLength.Text;
			int num = 0;
			if (!int.TryParse(text, out num) || num <= 0)
			{
				return;
			}
			if (this.lblYLength.Text.Contains("直径"))
			{
				double num2 = (double)(num / 2);
				double val = 0.0;
				if (!double.TryParse(this.cmbXLength.Text, out val) || !Geometry.IsEqual(num2, val))
				{
					if (Geometry.LessThan((double)((int)num2), num2))
					{
						this.cmbXLength.Text = num2.ToString("f2");
					}
					else
					{
						this.cmbXLength.Text = ((int)num2).ToString();
					}
					this.m_ColumnData.Radius = this.cmbXLength.Text;
				}
			}
		}

		private void UpdateXLength()
		{
			string text = this.cmbXLength.Text;
			int num = 0;
			if (!int.TryParse(text, out num) || num <= 0)
			{
				return;
			}
			if (this.lblYLength.Text.Contains("直径"))
			{
				double num2 = (double)(num * 2);
				double val = 0.0;
				if (!double.TryParse(this.cmbYLength.Text, out val) || !Geometry.IsEqual(num2, val))
				{
					if (Geometry.LessThan((double)((int)num2), num2))
					{
						this.cmbYLength.Text = num2.ToString("f2");
					}
					else
					{
						this.cmbYLength.Text = ((int)num2).ToString();
					}
					this.m_ColumnData.Diameter = this.cmbYLength.Text;
				}
			}
		}

		private void UpdateShape()
		{
			if (this.cmbShape.Text == "矩形柱")
			{
				this.lblXLength.Text = "横向(mm)：";
				this.lblYLength.Text = "纵向(mm)：";
				this.cmbXLength.ComboBoxCtrl().Items.Clear();
				foreach (string item in this.m_ColumnData.GetLstXLength())
				{
					this.cmbXLength.AddItem(item);
				}
				this.cmbYLength.ComboBoxCtrl().Items.Clear();
				foreach (string item2 in this.m_ColumnData.GetLstYLength())
				{
					this.cmbYLength.AddItem(item2);
				}
				this.cmbXLength.Text = this.m_ColumnData.XLength;
				this.cmbYLength.Text = this.m_ColumnData.YLength;
			}
			else if (this.cmbShape.Text == "圆柱")
			{
				this.lblXLength.Text = "半径(mm)：";
				this.lblYLength.Text = "直径(mm)：";
				this.cmbXLength.ComboBoxCtrl().Items.Clear();
				foreach (string item3 in this.m_ColumnData.GetLstRadius())
				{
					this.cmbXLength.AddItem(item3);
				}
				this.cmbYLength.ComboBoxCtrl().Items.Clear();
				foreach (string item4 in this.m_ColumnData.GetLstDiameter())
				{
					this.cmbYLength.AddItem(item4);
				}
				this.cmbXLength.Text = this.m_ColumnData.Radius;
				this.cmbYLength.Text = this.m_ColumnData.Diameter;
			}
			this.Refresh2DImg();
		}

		private void UpdateShapeCur()
		{
			if (this.cmbCurShape.Text == "矩形柱")
			{
				this.lblCurXLength.Text = "横向(mm)：";
				this.lblCurYLength.Text = "纵向(mm)：";
				return;
			}
			if (this.cmbShape.Text == "圆柱")
			{
				this.lblCurXLength.Text = "半径(mm)：";
				this.lblCurYLength.Text = "直径(mm)：";
			}
		}

		private void cmbShape_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.UpdateShape();
		}

		private void ColumnInsertDlg_Load(object sender, EventArgs e)
		{
			this.m_hook = new MouseHook(this);
			this.m_hook.HookStart();
			this.IniData();
			base.Location = this.m_ColumnData.PointLocation;
			//base.Icon = Resource.YArchitechIcon;
			ColumnInsertDlg.SetCursorPos(base.Location.X + base.Width / 2, base.Location.Y + base.Height / 2);
		}

		private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
		{
			TreeNode selectedNode = this.treeView.SelectedNode;
			if (selectedNode == null)
			{
				return;
			}
			TreeNode parent = selectedNode.Parent;
			if (parent == null)
			{
				return;
			}
			TreeNode parent2 = parent.Parent;
			if (parent2 == null || (parent2.Text != "建筑" && parent2.Text != "结构"))
			{
				return;
			}
			this.SetDlgBySymbol(selectedNode.Tag as FamilySymbol);
		}

		private void SetDataToColumnData()
		{
			this.m_ColumnData.Major = this.cmbMajor.Text;
			this.m_ColumnData.Shape = this.cmbShape.Text;
			this.m_ColumnData.Material = this.cmbMaterial.Text;
			this.SetDefaultDataToCrol();
			this.m_ColumnData.PointLocation = base.Location;
			this.SetTreeDataToColumnData();
		}

		private void SetTreeDataToColumnData()
		{
			try
			{
				TreeNode tNode = this.treeView.Nodes[0].Nodes[0];
				this.m_ColumnData.AddArchRectFiSymbol(this.GetChildNodesText(tNode));
				tNode = this.treeView.Nodes[0].Nodes[1];
				this.m_ColumnData.AddArchCircleFiSymbol(this.GetChildNodesText(tNode));
				tNode = this.treeView.Nodes[0].Nodes[2];
				this.m_ColumnData.AddArchOtherFiSymbol(this.GetChildNodesText(tNode));
				tNode = this.treeView.Nodes[1].Nodes[0];
				this.m_ColumnData.AddStruRectFiSymbol(this.GetChildNodesText(tNode));
				tNode = this.treeView.Nodes[1].Nodes[1];
				this.m_ColumnData.AddStruCircleFiSymbol(this.GetChildNodesText(tNode));
				tNode = this.treeView.Nodes[1].Nodes[2];
				this.m_ColumnData.AddStruOtherFiSymbol(this.GetChildNodesText(tNode));
			}
			catch
			{
			}
		}

		private List<string> GetChildNodesText(TreeNode tNode)
		{
			List<string> list = new List<string>();
			if (tNode == null)
			{
				return list;
			}
			foreach (object obj in tNode.Nodes)
			{
				TreeNode treeNode = (TreeNode)obj;
				if (treeNode != null)
				{
					list.Add(treeNode.Text);
				}
			}
			return list;
		}

		private void ColumnInsertDlg_FormClosed(object sender, FormClosedEventArgs e)
		{
			this.SetDataToColumnData();
			this.m_ColumnData.WriteDataToIni();
			if (this.m_hook != null)
			{
				this.m_hook.HookStop();
			}
			this.m_bIsDlgClosed = true;
			this.SetFocusToRevit();
			this.SendESC();
		}

		private void cmbCurShape_TextChanged(object sender, EventArgs e)
		{
			this.UpdateShapeCur();
		}

		private void cmbXLength_KeyPress(object sender, KeyPressEventArgs e)
		{
			if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '\b')
			{
				e.Handled = true;
			}
		}

		private void cmbYLength_KeyPress(object sender, KeyPressEventArgs e)
		{
			if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '\b')
			{
				e.Handled = true;
			}
		}

		private void cmbHeight_KeyPress(object sender, KeyPressEventArgs e)
		{
			if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '\b')
			{
				e.Handled = true;
			}
		}

		private void cmbBaseOffset_KeyPress(object sender, KeyPressEventArgs e)
		{
			if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '-' && e.KeyChar != '\b')
			{
				e.Handled = true;
			}
		}

		private void cmbCorner_KeyPress(object sender, KeyPressEventArgs e)
		{
			if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '-' && e.KeyChar != '\b')
			{
				e.Handled = true;
			}
		}

		private void cmbCurHeight_KeyPress(object sender, KeyPressEventArgs e)
		{
			if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '\b')
			{
				e.Handled = true;
			}
		}

		private void cmbCurBaseOffset_KeyPress(object sender, KeyPressEventArgs e)
		{
			if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '-' && e.KeyChar != '\b')
			{
				e.Handled = true;
			}
		}

		private void cmbCurCorner_KeyPress(object sender, KeyPressEventArgs e)
		{
			if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '-' && e.KeyChar != '\b')
			{
				e.Handled = true;
			}
		}

		private void treeView_ItemDrag(object sender, ItemDragEventArgs e)
		{
			base.DoDragDrop(e.Item, DragDropEffects.Move);
		}

		private void treeView_DragEnter(object sender, DragEventArgs e)
		{
			if (e.Data.GetDataPresent(typeof(TreeNode)))
			{
				e.Effect = DragDropEffects.Move;
				return;
			}
			e.Effect = DragDropEffects.None;
		}

		private void treeView_DragDrop(object sender, DragEventArgs e)
		{
			TreeNode treeNode = null;
			if (e.Data.GetDataPresent(typeof(TreeNode)))
			{
				treeNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
			}
			else
			{
				MessageBox.Show("error");
			}
            System.Drawing.Point point = default(System.Drawing.Point);
			point.X = e.X;
			point.Y = e.Y;
			point = this.treeView.PointToClient(point);
			TreeNode nodeAt = this.treeView.GetNodeAt(point);
			try
			{
				if (!(treeNode.Parent.Parent.Text != "建筑") || !(treeNode.Parent.Parent.Text != "结构"))
				{
					TreeNode parent = treeNode.Parent;
					if (nodeAt != null && nodeAt.Parent != treeNode && nodeAt != treeNode)
					{
						treeNode.Remove();
						int index = parent.Nodes.IndexOf(nodeAt);
						parent.Nodes.Insert(index, treeNode);
					}
				}
			}
			catch
			{
			}
		}

		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		[DllImport("user32.dll")]
		public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

		private void SendESC()
		{
			byte bVk = 27;
			int dwFlags = 0;
			int dwFlags2 = 2;
			int wMsg = 7;
			ColumnInsertDlg.SendMessage(this.m_iHandle, wMsg, IntPtr.Zero, IntPtr.Zero);
			ColumnInsertDlg.keybd_event(bVk, 0, dwFlags, 0);
			ColumnInsertDlg.keybd_event(bVk, 0, dwFlags2, 0);
		}

		private void SetFocusToRevit()
		{
			int wMsg = 7;
			ColumnInsertDlg.SendMessage(this.m_iHandle, wMsg, IntPtr.Zero, IntPtr.Zero);
		}

		private double GetCurLevelHeight(Document doc)
		{
			this.m_dCurHeight = 0.0;
			ElementId eleId = this.m_doc.ActiveView.GenLevel.Id;
			if (this.m_sortLevels.Count == 0)
			{
				this.m_sortLevels = Common.GetSortLevels(doc, double.MinValue, double.MaxValue);
			}
			int num = this.m_sortLevels.FindIndex((Level level) => eleId == level.Id);
			if (num != -1 && num < this.m_sortLevels.Count - 1)
			{
				this.m_dCurHeight = this.m_sortLevels[num + 1].Elevation - this.m_sortLevels[num].Elevation;
			}
			return Common.FeetToMM(this.m_dCurHeight);
		}

		[DllImport("user32.dll")]
		private static extern bool SetCursorPos(int X, int Y);

		private bool LayOut()
		{
			int num = 0;
			string text = "";
			if (this.tab.SelectedIndex == 0)
			{
				if (!int.TryParse(this.cmbXLength.Text, out num) || num <= 0)
				{
					if (text == "")
					{
						this.cmbXLength.SetFocus();
					}
					if (this.lblXLength.Text.Contains("半径"))
					{
						text = "[半径]数值错误，请输入大于0的整数";
					}
					else
					{
						text = "[横向]数值错误，请输入大于0的整数";
					}
				}
				if (!int.TryParse(this.cmbYLength.Text, out num) || num <= 0)
				{
					if (text == "")
					{
						this.cmbYLength.SetFocus();
					}
					if (this.lblXLength.Text.Contains("直径"))
					{
						text += "\n[纵向]数值错误，请输入大于0的整数";
					}
					else
					{
						text += "\n[纵向]数值错误，请输入大于0的整数";
					}
				}
				if (this.cmbHeight.Text == "当前层高" && Geometry.LessThan(this.m_dCurHeight, 1.0))
				{
					if (text == "")
					{
						this.cmbHeight.SetFocus();
					}
					text += "\n[柱高]数值错误，请输入大于0的整数";
				}
				if (this.cmbHeight.Text != "当前层高" && (!int.TryParse(this.cmbHeight.Text, out num) || num <= 0))
				{
					if (text == "")
					{
						this.cmbHeight.SetFocus();
					}
					text += "\n[柱高]数值错误，请输入大于0的整数";
				}
				if (!int.TryParse(this.cmbBaseOffset.Text, out num))
				{
					if (text == "")
					{
						this.cmbBaseOffset.SetFocus();
					}
					text += "\n[柱底偏移]数值错误，请输入整数";
				}
				if (!int.TryParse(this.cmbCorner.Text, out num) || num < -360 || num > 360)
				{
					if (text == "")
					{
						this.cmbCorner.SetFocus();
					}
					text += "\n[转角]数值错误，取值范围±360°以内的整数";
				}
			}
			else
			{
				if (this.cmbCurHeight.Text == "当前层高" && Geometry.LessThan(this.m_dCurHeight, 1.0))
				{
					if (text == "")
					{
						this.cmbCurHeight.SetFocus();
					}
					text += "\n[柱高]数值错误，请输入大于0的整数";
				}
				if (this.cmbCurHeight.Text != "当前层高" && (!int.TryParse(this.cmbCurHeight.Text, out num) || num <= 0))
				{
					if (text == "")
					{
						this.cmbCurHeight.SetFocus();
					}
					text = "\n[柱高]数值错误，请输入大于0的整数";
				}
				if (!int.TryParse(this.cmbCurBaseOffset.Text, out num))
				{
					if (text == "")
					{
						this.cmbCurBaseOffset.SetFocus();
					}
					text += "\n[柱底偏移]数值错误，请输入整数";
				}
				if (!int.TryParse(this.cmbCurCorner.Text, out num) || num < -360 || num > 360)
				{
					if (text == "")
					{
						this.cmbCurCorner.SetFocus();
					}
					text += "\n[转角]数值错误，取值范围±360°以内的整数";
				}
			}
			if (text == "")
			{
				return true;
			}
			if (!this.m_bMessageBoxShow)
			{
				this.m_bMessageBoxShow = true;
				if (YJKMessageBox.Show(text, MessageBoxButtons.OK) != DialogResult.None)
				{
					this.m_bMessageBoxShow = false;
				}
				ColumnInsertDlg.SetCursorPos(base.Location.X + base.Width / 2, base.Location.Y + (int)((double)base.Height * 0.7));
			}
			return false;
		}

		private bool GetAngle(ref double angle)
		{
			try
			{
				XLineJig xlineJig = new XLineJig(this.m_Uidoc);
				xlineJig.ResetPoint = XUiJigBase.EResetPoint.eByAxis;
				XYZ xyz = this.m_Uidoc.Selection.PickPoint("选择起始边起点");
				if (xyz == null)
				{
					xlineJig.Dispose();
				}
				XYZ xyz2 = xlineJig.PickEndPoint(xyz, "选择起始边终点");
				xlineJig.Dispose();
				double angle2 = Geometry.getAngle(XYZ.Zero, xyz2 - xyz);
				double angle3 = Geometry.getAngle(XYZ.Zero, XYZ.BasisX);
				angle = Geometry.BetweenTheAngles(angle3, angle2, true);
				angle = Geometry.formatAngle(angle);
			}
			catch (Exception)
			{
				angle = 0.0;
				return false;
			}
			return true;
		}

		private void btnCorner_Click(object sender, EventArgs e)
		{
			base.Hide();
			this.m_bDoHook = false;
			try
			{
				this.m_bIsLevelDlg = true;
				double num = 0.0;
				if (this.GetAngle(ref num))
				{
					num = num * 180.0 / Math.PI;
					int num2 = (int)num;
					if (Geometry.LessThan(num - (double)num2, 0.5))
					{
						num2++;
					}
					this.cmbCorner.Text = num2.ToString();
				}
			}
			catch (Exception)
			{
			}
			base.Show();
			this.SetCurPosToCtrl(this.cmbCorner);
			this.m_bDoHook = true;
		}

		private void ColumnInsertDlg_KeyDown(object sender, KeyEventArgs e)
		{
			try
			{
				Keys keyCode = e.KeyCode;
				if (keyCode == Keys.Escape && !this.m_bIsLevelDlg)
				{
					base.Close();
				}
			}
			catch
			{
			}
		}

		[DllImport("user32.dll")]
		public static extern IntPtr GetActiveWindow();

		[DllImport("user32.dll")]
		public static extern IntPtr SetActiveWindow(IntPtr hwnd);

		private void MouseLeaveForm()
		{
			if (base.ClientRectangle.Contains(base.PointToClient(Cursor.Position)))
			{
				ColumnInsertDlg.SetActiveWindow(base.Handle);
				base.Activate();
				base.Focus();
				return;
			}
			if (this.m_eCreateColumnType != CreateColumnType.ePickupColumn && !this.LayOut())
			{
				base.Focus();
				return;
			}
			if (this.m_eCreateColumnType != CreateColumnType.ePickupColumn)
			{
				this.SetDefaultDataToCrol();
			}
			this.SetFocusToRevit();
			this.SendESC();
			this.m_bIsLevelDlg = true;
		}

		protected override void DefWndProc(ref Message m)
		{
			int msg = m.Msg;
			if (msg == 1125)
			{
				if (this.m_bDoHook && !this.m_bIsLevelDlg)
				{
					this.MouseLeaveForm();
					return;
				}
			}
			else
			{
				base.DefWndProc(ref m);
			}
		}

		private void SetDefaultXLengthNew()
		{
			int num = 0;
			if (!int.TryParse(this.cmbXLength.Text, out num) || num <= 0)
			{
				return;
			}
			this.cmbXLength.ComboBoxCtrl().Items.Clear();
			if (this.lblXLength.Text.Contains("半径"))
			{
				this.m_ColumnData.AddRadius(this.cmbXLength.Text);
				foreach (string item in this.m_ColumnData.GetLstRadius())
				{
					this.cmbXLength.AddItem(item);
				}
				this.m_ColumnData.Radius = this.cmbXLength.Text;
				return;
			}
			this.m_ColumnData.AddXLength(this.cmbXLength.Text);
			foreach (string item2 in this.m_ColumnData.GetLstXLength())
			{
				this.cmbXLength.AddItem(item2);
			}
			this.m_ColumnData.XLength = this.cmbXLength.Text;
		}

		private void SetDefaultYLengthNew()
		{
			int num = 0;
			if (!int.TryParse(this.cmbYLength.Text, out num) || num <= 0)
			{
				return;
			}
			this.cmbYLength.ComboBoxCtrl().Items.Clear();
			if (this.lblYLength.Text.Contains("直径"))
			{
				this.m_ColumnData.AddDiameter(this.cmbYLength.Text);
				foreach (string item in this.m_ColumnData.GetLstDiameter())
				{
					this.cmbYLength.AddItem(item);
				}
				this.m_ColumnData.Diameter = this.cmbYLength.Text;
				return;
			}
			this.m_ColumnData.AddYLength(this.cmbYLength.Text);
			foreach (string item2 in this.m_ColumnData.GetLstYLength())
			{
				this.cmbYLength.AddItem(item2);
			}
			this.m_ColumnData.YLength = this.cmbYLength.Text;
		}

		private void SetDefaultHeight()
		{
			int num = 0;
			if (this.cmbHeight.Text == "当前层高" && Geometry.LessThan(this.m_dCurHeight, 1.0))
			{
				return;
			}
			if (this.cmbHeight.Text != "当前层高" && (!int.TryParse(this.cmbHeight.Text, out num) || num <= 0))
			{
				return;
			}
			this.cmbHeight.ComboBoxCtrl().Items.Clear();
			this.m_ColumnData.AddHeight(this.cmbHeight.Text);
			foreach (string item in this.m_ColumnData.GetLstHeight())
			{
				this.cmbHeight.AddItem(item);
			}
			this.m_ColumnData.Height = this.cmbHeight.Text;
		}

		private void SetDefaultBaseOffset()
		{
			int num = 0;
			if (!int.TryParse(this.cmbBaseOffset.Text, out num))
			{
				return;
			}
			this.cmbBaseOffset.ComboBoxCtrl().Items.Clear();
			this.m_ColumnData.AddBaseOffset(this.cmbBaseOffset.Text);
			foreach (string item in this.m_ColumnData.GetLstBaseOffset())
			{
				this.cmbBaseOffset.AddItem(item);
			}
			this.m_ColumnData.BaseOffset = this.cmbBaseOffset.Text;
		}

		private void SetDefaultCorner()
		{
			int num = 0;
			if (!int.TryParse(this.cmbCorner.Text, out num) || num < -360 || num > 360)
			{
				return;
			}
			this.cmbCorner.ComboBoxCtrl().Items.Clear();
			this.m_ColumnData.AddCorner(this.cmbCorner.Text);
			foreach (string item in this.m_ColumnData.GetLstCorner())
			{
				this.cmbCorner.AddItem(item);
			}
			this.m_ColumnData.Corner = this.cmbCorner.Text;
		}

		private void SetDefaultHeightCur()
		{
			int num = 0;
			if (this.cmbCurHeight.Text == "当前层高" && Geometry.LessThan(this.m_dCurHeight, 1.0))
			{
				return;
			}
			if (this.cmbCurHeight.Text != "当前层高" && (!int.TryParse(this.cmbCurHeight.Text, out num) || num <= 0))
			{
				return;
			}
			this.cmbCurHeight.ComboBoxCtrl().Items.Clear();
			this.m_ColumnData.AddHeightCur(this.cmbCurHeight.Text);
			foreach (string item in this.m_ColumnData.GetLstHeightCur())
			{
				this.cmbCurHeight.AddItem(item);
			}
			this.m_ColumnData.HeightCur = this.cmbCurHeight.Text;
		}

		private void SetDefaultBaseOffsetCur()
		{
			int num = 0;
			if (!int.TryParse(this.cmbCurBaseOffset.Text, out num))
			{
				return;
			}
			this.cmbCurBaseOffset.ComboBoxCtrl().Items.Clear();
			this.m_ColumnData.AddBaseOffsetCur(this.cmbCurBaseOffset.Text);
			foreach (string item in this.m_ColumnData.GetLstBaseOffsetCur())
			{
				this.cmbCurBaseOffset.AddItem(item);
			}
			this.m_ColumnData.BaseOffsetCur = this.cmbCurBaseOffset.Text;
		}

		private void SetDefaultCornerCur()
		{
			int num = 0;
			if (!int.TryParse(this.cmbCurCorner.Text, out num) || num < -360 || num > 360)
			{
				return;
			}
			this.cmbCurCorner.ComboBoxCtrl().Items.Clear();
			this.m_ColumnData.AddCornerCur(this.cmbCurCorner.Text);
			foreach (string item in this.m_ColumnData.GetLstCornerCur())
			{
				this.cmbCurCorner.AddItem(item);
			}
			this.m_ColumnData.CornerCur = this.cmbCurCorner.Text;
		}

		private void SetDefaultDataToCrol()
		{
			if (this.tab.SelectedIndex == 0)
			{
				this.SetDefaultXLengthNew();
				this.SetDefaultYLengthNew();
				this.SetDefaultHeight();
				this.SetDefaultBaseOffset();
				this.SetDefaultCorner();
				return;
			}
			this.SetDefaultHeightCur();
			this.SetDefaultBaseOffsetCur();
			this.SetDefaultCornerCur();
		}

		private void Refresh2DImg(object sender, EventArgs e)
		{
			if (this.tab.SelectedIndex == 0)
			{
				if (this.cmbXLength.ContainsFocus)
				{
					this.UpdateXLength();
				}
				else if (this.cmbYLength.ContainsFocus)
				{
					this.UpdateYLength();
				}
			}
			this.Refresh2DImg();
		}

		private void Refresh2DImg()
		{
			List<CurveInfo> list = new List<CurveInfo>();
			if (this.tab.SelectedIndex == 0)
			{
				if (this.m_lstCvInfoNew.Count > 0)
				{
					list = this.m_lstCvInfoNew;
				}
				else
				{
					list = this.GetCrusorCvInfo(ref this.m_ptCenterNew);
				}
				list.AddRange(this.GetColumnShapeInfo(this.m_ptCenterNew));
				this.m_PreviewNew.Curves = list;
				this.m_PreviewNew.Refresh();
				return;
			}
			if (this.m_lstCvInfoCur.Count == 0)
			{
				list = this.GetCrusorCvInfo(ref this.m_ptCenterCur);
			}
			else
			{
				list = this.m_lstCvInfoCur;
			}
			list.AddRange(this.GetColumnShapeInfo(this.m_ptCenterCur));
			this.m_PreviewCur.Curves = list;
			this.m_PreviewCur.Refresh();
		}

		private List<CurveInfo> GetColumnShapeInfo(XYZ ptCenter)
		{
			int num = 0;
			double num2 = 0.0;
			double num3 = 0.0;
			List<CurveInfo> list = new List<CurveInfo>();
			if (this.tab.SelectedIndex == 0)
			{
				if (this.cmbShape.Text == "圆柱")
				{
					list.AddRange(this.NewArc(PenColor.PC_Gray, this.m_dLineWidth, ptCenter, this.m_dRadius));
					return list;
				}
				if (!int.TryParse(this.cmbCorner.Text, out num))
				{
					return list;
				}
				if (!double.TryParse(this.cmbXLength.Text, out num2))
				{
					return list;
				}
				if (!double.TryParse(this.cmbYLength.Text, out num3))
				{
					return list;
				}
			}
			else
			{
				if (this.cmbCurShape.Text == "圆柱")
				{
					list.AddRange(this.NewArc(PenColor.PC_Gray, this.m_dLineWidth, ptCenter, this.m_dRadius));
					return list;
				}
				if (!int.TryParse(this.cmbCurCorner.Text, out num))
				{
					return list;
				}
				if (!double.TryParse(this.cmbCurXLength.Text, out num2))
				{
					return list;
				}
				if (!double.TryParse(this.cmbCurYLength.Text, out num3))
				{
					return list;
				}
			}
			if (Geometry.Lessthan_Or_Equal(num2, 1E-06) || Geometry.Lessthan_Or_Equal(num3, 1E-06))
			{
				return list;
			}
			if (Geometry.LessThan(num2, num3))
			{
				double num4 = num2 / num3;
				num3 = this.m_dRadius;
				num2 = num4 * num3;
			}
			else
			{
				double num5 = num3 / num2;
				num2 = this.m_dRadius;
				num3 = num5 * num2;
			}
			XYZ xyz = new XYZ(ptCenter.X - num2, ptCenter.Y - num3, 0.0);
			XYZ xyz2 = new XYZ(ptCenter.X + num2, ptCenter.Y - num3, 0.0);
			XYZ xyz3 = new XYZ(ptCenter.X - num2, ptCenter.Y + num3, 0.0);
			XYZ xyz4 = new XYZ(ptCenter.X + num2, ptCenter.Y + num3, 0.0);
			double angle = AssistFunc.AngleToRadian((double)num);
			xyz = Geometry.RotateTo(xyz, ptCenter, XYZ.BasisZ, angle);
			xyz2 = Geometry.RotateTo(xyz2, ptCenter, XYZ.BasisZ, angle);
			xyz3 = Geometry.RotateTo(xyz3, ptCenter, XYZ.BasisZ, angle);
			xyz4 = Geometry.RotateTo(xyz4, ptCenter, XYZ.BasisZ, angle);
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, xyz, xyz2));
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, xyz, xyz3));
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, xyz2, xyz4));
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, xyz3, xyz4));
			return list;
		}

		private List<CurveInfo> GetCrusorCvInfo(ref XYZ ptCenter)
		{
			PictureBox pictureBox = this.picPreview;
			if (this.tab.SelectedIndex != 0)
			{
				if (this.m_lstCvInfoCur.Count > 0)
				{
					return null;
				}
				pictureBox = this.picCurPreview;
			}
			else
			{
				if (this.m_lstCvInfoCur.Count > 0)
				{
					return null;
				}
				pictureBox = this.picPreview;
			}
			int num = pictureBox.Left + pictureBox.Width / 2;
			int num2 = pictureBox.Top + pictureBox.Height / 2;
			XYZ xyz = new XYZ((double)num, (double)(pictureBox.Top + num2 / 8), 0.0);
			XYZ xyz2 = new XYZ((double)num, (double)(num2 + 7 * num2 / 8), 0.0);
			ptCenter = (xyz + xyz2) / 2.0;
			XYZ ptS = new XYZ((double)(pictureBox.Left + num / 8), ptCenter.Y, 0.0);
			XYZ ptE = new XYZ((double)(num + 7 * num / 8), ptCenter.Y, 0.0);
			List<CurveInfo> list = new List<CurveInfo>();
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, ptS, ptE));
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, xyz, xyz2));
			XYZ ptS2 = new XYZ((double)num - this.m_dRectCurSor, ptCenter.Y - this.m_dRectCurSor, 0.0);
			XYZ xyz3 = new XYZ((double)num + this.m_dRectCurSor, ptCenter.Y - this.m_dRectCurSor, 0.0);
			XYZ xyz4 = new XYZ((double)num - this.m_dRectCurSor, ptCenter.Y + this.m_dRectCurSor, 0.0);
			XYZ ptE2 = new XYZ((double)num + this.m_dRectCurSor, ptCenter.Y + this.m_dRectCurSor, 0.0);
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, ptS2, xyz3));
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, ptS2, xyz4));
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, xyz3, ptE2));
			list.Add(this.NewLine(PenColor.PC_Gray, this.m_dLineWidth, xyz4, ptE2));
			return list;
		}

		private List<CurveInfo> NewArc(PenColor color, float dLineWidth, XYZ ptCenter, double dRadius)
		{
			Transform identity = Transform.Identity;
			Transform identity2 = Transform.Identity;
			Transform identity3 = Transform.Identity;
			Transform transform = identity.Multiply(identity2);
			transform = transform.Multiply(identity3);
			ptCenter = Geometry.TransformPoint(ptCenter, transform);
			Plane plane = RevitVersionFuncs.CreatePlanByNormalAndOrigin(XYZ.BasisZ, ptCenter);
			List<CurveInfo> list = new List<CurveInfo>();
			try
			{
				Arc curve = Arc.Create(plane, dRadius, 0.0, Math.PI);
				list.Add(new CurveInfo(curve, color, dLineWidth));
				curve = Arc.Create(plane, dRadius, Math.PI, Math.PI*2);
				list.Add(new CurveInfo(curve, color, dLineWidth));
			}
			catch (Exception)
			{
			}
			return list;
		}

		private CurveInfo NewLine(PenColor color, float dLineWidth, XYZ ptS, XYZ ptE)
		{
			Transform identity = Transform.Identity;
			Transform identity2 = Transform.Identity;
			Transform identity3 = Transform.Identity;
			Transform transform = identity.Multiply(identity2);
			transform = transform.Multiply(identity3);
			XYZ xyz = Geometry.TransformPoint(ptS, transform);
			XYZ xyz2 = Geometry.TransformPoint(ptE, transform);
			Line curve = null;
			CurveInfo result;
			try
			{
				curve = Line.CreateBound(xyz, xyz2);
				result = new CurveInfo(curve, color, dLineWidth);
			}
			catch (Exception)
			{
				result = new CurveInfo(curve, color, dLineWidth);
			}
			return result;
		}

		private void btnPickPt_Click(object sender, EventArgs e)
		{
			this.m_eCreateColumnType = CreateColumnType.eSelectPoint;
			this.m_bDoHook = true;
		}

		private void btnPickAxis_Click(object sender, EventArgs e)
		{
			this.m_eCreateColumnType = CreateColumnType.eSelectAxis;
			this.m_bDoHook = true;
		}

		private void btnPickRect_Click(object sender, EventArgs e)
		{
			this.m_eCreateColumnType = CreateColumnType.eSelectGrids;
			this.m_bDoHook = true;
		}

		private void btnClone_Click(object sender, EventArgs e)
		{
			this.m_eCreateColumnType = CreateColumnType.ePainter;
			this.m_bDoHook = true;
		}

		private void btnPickColumn_Click(object sender, EventArgs e)
		{
			this.m_eCreateColumnType = CreateColumnType.ePickupColumn;
			this.m_bDoHook = true;
		}

		private void SetCurPosToCtrl(YArchitech.Controls.YJKComboBox comBox)
		{
			int x = base.Location.X + this.hyGroupBoxColumnInfo.Location.X + comBox.Location.X + comBox.Width + 20;
			int y = base.Location.Y + this.hyGroupBoxColumnInfo.Location.Y + comBox.Location.Y + comBox.Height / 2 + 70;
			ColumnInsertDlg.SetCursorPos(x, y);
			comBox.SetFocus();
		}

		private void cmbXLength_cmbSelectedChanged(object sender, EventArgs e)
		{
			this.SetCurPosToCtrl(this.cmbXLength);
			this.UpdateXLength();
			this.Refresh2DImg();
		}

		private void cmbYLength_cmbSelectedChanged(object sender, EventArgs e)
		{
			this.SetCurPosToCtrl(this.cmbYLength);
			this.UpdateYLength();
			this.Refresh2DImg();
		}

		private void cmbHeight_cmbSelectedChanged(object sender, EventArgs e)
		{
			this.SetCurPosToCtrl(this.cmbHeight);
		}

		private void cmbBaseOffset_cmbSelectedChanged(object sender, EventArgs e)
		{
			this.SetCurPosToCtrl(this.cmbBaseOffset);
		}

		private void cmbCorner_cmbSelectedChanged(object sender, EventArgs e)
		{
			this.SetCurPosToCtrl(this.cmbCorner);
			this.Refresh2DImg();
		}

		private void cmbCurHeight_cmbSelectedChanged(object sender, EventArgs e)
		{
			this.SetCurPosToCtrl(this.cmbCurHeight);
		}

		private void cmbCurBaseOffset_cmbSelectedChanged(object sender, EventArgs e)
		{
			this.SetCurPosToCtrl(this.cmbCurBaseOffset);
		}

		private void cmbCurCorner_cmbSelectedChanged(object sender, EventArgs e)
		{
			this.SetCurPosToCtrl(this.cmbCurCorner);
			this.Refresh2DImg();
		}

		private const PenColor m_CurveColor = PenColor.PC_Gray;

		private UIDocument m_Uidoc;

		private Document m_doc;

		private ColumnInsetData m_ColumnData;

		private CreateColumnType m_eCreateColumnType;

		private Previewer m_PreviewNew;

		private Previewer m_PreviewCur;

		private float m_dLineWidth = 1f;

		private double m_dRadius = 60.0;

		private double m_dRectCurSor = 5.0;

		private List<CurveInfo> m_lstCvInfoNew = new List<CurveInfo>();

		private List<CurveInfo> m_lstCvInfoCur = new List<CurveInfo>();

		private XYZ m_ptCenterNew = new XYZ();

		private XYZ m_ptCenterCur = new XYZ();

		private MouseHook m_hook;

		private FamilySymbolManage m_fySymbolManage;

		private double m_dCurHeight;

		private List<Level> m_sortLevels = new List<Level>();

		private IntPtr m_iHandle;

		public bool m_bIsDlgClosed;

		public bool m_bIsLevelDlg;

		public bool m_bDoHook = true;

		private bool m_bMessageBoxShow;
	}
}
